package com.ruoyi.customerService.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.customerService.domain.SheetChannel;
import com.ruoyi.customerService.domain.SheetType;
import com.ruoyi.customerService.service.SheetChannelService;
import com.ruoyi.customerService.service.SheetTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cs/sheetType")
@Api(tags = "客服中心-工单类型")
public class SheetTypeController {
    @Autowired
    private SheetTypeService sheetTypeService;
    @ApiOperation("查全部")
    @GetMapping("/selectAll")
    public R selectAll() {
        List<SheetType> sheetTypes = sheetTypeService.selectAll();
        if (sheetTypes == null || sheetTypes.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(sheetTypes);
        }
    }

    @ApiOperation("添加")
    @PostMapping("/insert")
    public R insert(@RequestBody SheetType sheetType){
        Boolean isAdd = sheetTypeService.insert(sheetType);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public R update(@RequestBody SheetType sheetType){
        Boolean isUpdate = sheetTypeService.update(sheetType);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public R delete(Integer id){
        Boolean isDelete = sheetTypeService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }


}
